<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<!--
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
-->
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
$(function(){
  //搜索功能
  $("#search").click(function(){
    var url = $(this).attr('url');
    var segment = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
    if(segment != ''){
      if(query != ''){
        query += '&segment=' + segment;
        }else{
        query += 'segment=' + segment;
        }
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
    window.location.href = url;
  });

  /* 状态搜索子菜单 */
  $(".search-form").find(".drop-down").hover(function(){
    $("#sub-sch-menu").removeClass("hidden");
  },function(){
    $("#sub-sch-menu").addClass("hidden");
  });
  $("#sub-sch-menu li").find("a").each(function(){
    $(this).click(function(){
      var text = $(this).text();
      $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
      $("#sub-sch-menu").addClass("hidden");
    })
  });

  //点击排序
  $('.list_sort').click(function(){
    var url = $(this).attr('url');
    var ids = $('.ids:checked');
    var param = '';
    if(ids.length > 0){
      var str = new Array();
      ids.each(function(){
        str.push($(this).val());
      });
      param = str.join(',');
    }

    if(url != undefined && url != ''){
      window.location.href = url + '/ids/' + param;
    }
  });

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $('#time-start').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
      minView:2,
      autoclose:true
    });

    $('#time-end').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
      minView:2,
      autoclose:true
    });
    
    
	$('#submit').click(function(){
	  $('#form').submit();
	});
	
	$(function(){
	    $('.time').datetimepicker({
	        format: 'yyyy-mm-dd',
	        language:"zh-CN",
	        minView:2,
	        autoclose:true
	    });
	    showTab();
	
	});

	/**
	 *查看内容快捷挂件
	 */
	$("a#list_category").click(function(){
        var url = "{:U('Admin/Wechat/contentGuide',array('segment'=>'category'))}";
        showMsgBox(url);
	});

	$("a#list_articles").click(function(){
        var url = "{:U('Admin/Wechat/contentGuide',array('segment'=>'article'))}";
        showMsgBox(url);
	});

	$("a#list_text").click(function(){
        var url = "{:U('Admin/Wechat/contentGuide',array('segment'=>'text'))}";
        showMsgBox(url);
	});

    /**
     * 小工具，清理缓存
     */
    $("#cache-delete").click(function(){
        var url = "cc.php";
        showMsgBox(url);
    });

    /**
     * 小工具，检测与微信的连通
     */
    $("#check_connect").click(function(){
        var url = "{:U('Wechat/testWechatConnect')}";
        showMsgBox(url);
    });

 })

    function showMsgBox(url){
        $("div#msgModal").empty().text('正在操作中……');
        $.get(url,function(data){
            $("div#msgModal").html(data);
        });
    }

 	//关闭灰色 jQuery 遮罩
	function closeBg() {
	$("#dialog").hide();
	}
	
</script>